import java.util.Scanner;

public class Main1291 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n=sc.nextLine();
        System.out.println(Integer.                            parseInt(String.valueOf(n), 8));
        sc.nextLine();
    }
}
